package com.guchenbo.spark.core

import org.apache.spark.SparkContext

/**
 * @author guchenbo
 * @date 2022/3/4
 */
object RddDep {

  def main(args: Array[String]): Unit = {
    val conf = SparkUtils.conf("RddDep")
    val sc = new SparkContext(conf)

    //    内存
    val rdd1 = sc.makeRDD(List(1, 2, 3, 4, 5, 6))
    println("rdd1 dep: ",rdd1.dependencies)

    val rdd2 = rdd1.map((_, 1))
    println("rdd2 dep: ",rdd2.dependencies)

    val rdd3 = rdd2.filter(_._1 != 5)
    println("rdd3 dep: ",rdd3.dependencies)

    val rdd4 = rdd3.reduceByKey(_ + _)
    println("rdd4 dep: ",rdd4.dependencies)
    //    rdd4.collect().foreach(println)

    println("###############")
    println(rdd1.toDebugString)
    println(rdd2.toDebugString)
    println(rdd3.toDebugString)
    println(rdd4.toDebugString)
  }
}
